<?php
require_once( "include/incMain.php" );


$mapW = $_REQUEST['mapW']; 
$mapH = $_REQUEST['mapH']; 
$mapX = $_REQUEST['mapX']; 
$mapY = $_REQUEST['mapY']; 
$mapZ = $_REQUEST['mapZ']; 


if($mapW=="") $mapW = 500;
if($mapH=="") $mapH = 500;
if($mapX=="") $mapX = 0;
if($mapY=="") $mapY = 0;
if($mapZ=="") $mapZ = 1;


$halfW = ($mapW/2);
$halfH = ($mapH/2);


$xMin = ($mapX - $halfW ) / $mapZ;
$xMax = ($mapX + $halfW ) / $mapZ;
$yMin = ($mapY - $halfH ) / $mapZ;
$yMax = ($mapY + $halfH ) / $mapZ;



// get close object coordinates
$sql = "SELECT x, y, name FROM objects WHERE X > $xMin AND X < $xMax AND Y > $yMin AND Y < $yMax ";
$result = sql($sql);
while($row = mysql_fetch_array( $result )) {
    
    // relative Positions
    if($mapX==$row['x'] && $mapY==$row['y']) $name = "<b>".$row['name']."</b>";
    else $name = $row['name'];
    
    $positions[] = array( "x" => $row['x'], "y" => $row['y'], "name" => $name );

}





$smarty = new mySmarty();

$smarty->assign("mapW", $mapW );
$smarty->assign("mapH", $mapH );
$smarty->assign("mapX", $mapX );
$smarty->assign("mapY", $mapY );
$smarty->assign("mapZ", $mapZ );
$smarty->assign("mapMove", 100 );

$smarty->assign("positions", $positions );

$smarty->assign("Path", glPath );
$smarty->assign("menue", getMenue(5) );
$smarty->display(glPath.'/map.htm');


?>
